package com.cy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.entity.Manager;
import com.cy.entity.ManagerExample;
import com.cy.mapper.ManagerMapper;

@Service
public class ManagerService {
	@Autowired
	private ManagerMapper mapper;
	
	public List<Manager> findAllManager() {
		return mapper.selectByExample(null);
	}
	
	public Manager findManagerById(Integer id) {
		return mapper.selectByPrimaryKey(id);
	}
	
	public List<Manager> findByManagerTelForFuzzy(String tel){
		ManagerExample me = new ManagerExample();
		me.createCriteria().andManagertelLike("%"+tel+"%");
		return mapper.selectByExample(me);
	}
	
	public List<Manager> findByManagerTel(String tel){
		ManagerExample me = new ManagerExample();
		me.createCriteria().andManagertelEqualTo(tel);
		return mapper.selectByExample(me);
	}
	
	
	public void addManager(Manager manager) {
		mapper.insert(manager);
	}
	
	public void updateManager(Manager manager) {
		ManagerExample me = new ManagerExample();
		me.createCriteria().andManageridEqualTo(manager.getManagerid());
		mapper.updateByPrimaryKey(manager);
	}
	
	public void deleteManager(Integer id) {
		mapper.deleteByPrimaryKey(id);
	}
}
